import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;


public class AddSemiColonToFreq {

	public static void main(String[] args) {
		
		String directory  = "F:/splitTrain/splitPerShow/N-grams/";
		
		ArrayList<File> fileList = new ArrayList<File>();
		
		fileList.add(new File(directory + "unigramEB.txt"));
		fileList.add(new File(directory + "bigramEB.txt"));
		fileList.add(new File(directory + "trigramEB.txt"));
		fileList.add(new File(directory + "unigramST.txt"));
		fileList.add(new File(directory + "bigramST.txt"));
		fileList.add(new File(directory + "trigramST.txt"));
		fileList.add(new File(directory + "unigramGGV.txt"));
		fileList.add(new File(directory + "bigramGGV.txt"));
		fileList.add(new File(directory + "trigramGGV.txt"));
		
		for(int i = 0 ; i < fileList.size(); i++){
			
			try {
				BufferedReader reader = new BufferedReader(new FileReader(fileList.get(i)));
				String outName = fileList.get(i).getAbsolutePath().substring(0,fileList.get(i).getAbsolutePath().length()-4);
				BufferedWriter writer = new BufferedWriter(new FileWriter(outName + "Fixed" + ".txt"));
				String line = reader.readLine();
	            while (line != null) {
	            	
	            	String a = "	";
	            	String[] split = line.split(a);
	            	String s = "";
	            	for(int j = 0 ; j < split.length-1; j ++){
	            		s = split[j];
	            	}
	            	s = s + ";" + split[split.length-1]; 
	            	writer.write(s + "\n");
	                line = reader.readLine();
	            }
	            reader.close();
				writer.close();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
		}
		
	}

}
